<template>
	<view style="height: 100%" v-if="content">
		<rich-text class="content1 db" :nodes="content"></rich-text>
		<view class="pob pd715 bgcf">
			<button class="sub" @tap="goSettled">立即入驻</button>
		</view>
	</view>
</template>

<script>
	import {
		verifyPhoneNumber
	} from "@/utils/util"
	const http = require('../../utils/http');
	export default {
		data() {
			return {
				content: {},
				callback: null
			};
		}
		/**
		 * 生命周期函数--监听页面加载
		 */
		,
		onLoad(options) {
			let token = uni.getStorageSync('token');

			if (token) {
				http.request('user/userInfo')
					.then((res) => {
						if (res.data.userInfo.grade === 0) {
							this.getContent();
						} else {
							uni.reLaunch({
								url: '/pages/demand/demand'
							});
						}
					})
					.catch((res) => {
						uni.reLaunch({
							url: '/pages/demand/demand'
						});
					});
			} else {
				this.getContent();
				// uni.reLaunch ({
				// 	url: '/pages/login/login'
				// });
			}
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow() {},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload() {
			clearTimeout(this.callback)
		},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom() {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage() {},
		methods: {
			goSettled() {
				// 验证是否登录，是否有手机号
				this.callback = verifyPhoneNumber()
				if (this.callback) return
				uni.navigateTo({
					url: '/pages/editSettled/editSettled'
				});
			},

			getContent() {
				http.request('base/pageCount')
					.then((res) => {
						let content = res.data.rzgys.replace(/<img/g, '<img class="rich-text-img"');
						this.setData({
							content: content
						});
					})
					.catch((res) => {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					});
			}
		}
	};
</script>
<style>
	@import './setPage.css';
</style>